* Step 1: DependencyPairs WORST_CASE(?,O(n^2)) + Considered Problem: - Strict TRS: minus(x,0()) -> x minus(x,s(y)) -> pred(minus(x,y)) pred(s(x)) -> x quot(0(),s(y)) -> 0() quot(s(x),s(y)) -> s(quot(minus(x,y),s(y))) - Signature: {minus/2,pred/1,quot/2} / {0/0,s/1} - Obligation: innermost runtime complexity wrt. defined symbols {minus,pred,quot} and constructors {0,s} + Applied Processor: DependencyPairs {dpKind_ = DT} + Details: We add the following dependency tuples: Strict DPs minus#(x,0()) -> c_1() minus#(x,s(y)) -> c_2(pred#(minus(x,y)),minus#(x,y)) pred#(s(x)) -> c_3() quot#(0(),s(y)) -> c_4() quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)) Weak DPs and mark the set of starting terms. * Step 2: UsableRules WORST_CASE(?,O(n^2)) + Considered Problem: - Strict DPs: minus#(x,0()) -> c_1() minus#(x,s(y)) -> c_2(pred#(minus(x,y)),minus#(x,y)) pred#(s(x)) -> c_3() quot#(0(),s(y)) -> c_4() quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)) - Weak TRS: minus(x,0()) -> x minus(x,s(y)) -> pred(minus(x,y)) pred(s(x)) -> x quot(0(),s(y)) -> 0() quot(s(x),s(y)) -> s(quot(minus(x,y),s(y))) - Signature: {minus/2,pred/1,quot/2,minus#/2,pred#/1,quot#/2} / {0/0,s/1,c_1/0,c_2/2,c_3/0,c_4/0,c_5/2} - Obligation: innermost runtime complexity wrt. defined symbols {minus#,pred#,quot#} and constructors {0,s} + Applied Processor: UsableRules + Details: We replace rewrite rules by usable rules: minus(x,0()) -> x minus(x,s(y)) -> pred(minus(x,y)) pred(s(x)) -> x minus#(x,0()) -> c_1() minus#(x,s(y)) -> c_2(pred#(minus(x,y)),minus#(x,y)) pred#(s(x)) -> c_3() quot#(0(),s(y)) -> c_4() quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)) * Step 3: PredecessorEstimation WORST_CASE(?,O(n^2)) + Considered Problem: - Strict DPs: minus#(x,0()) -> c_1() minus#(x,s(y)) -> c_2(pred#(minus(x,y)),minus#(x,y)) pred#(s(x)) -> c_3() quot#(0(),s(y)) -> c_4() quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)) - Weak TRS: minus(x,0()) -> x minus(x,s(y)) -> pred(minus(x,y)) pred(s(x)) -> x - Signature: {minus/2,pred/1,quot/2,minus#/2,pred#/1,quot#/2} / {0/0,s/1,c_1/0,c_2/2,c_3/0,c_4/0,c_5/2} - Obligation: innermost runtime complexity wrt. defined symbols {minus#,pred#,quot#} and constructors {0,s} + Applied Processor: PredecessorEstimation {onSelection = all simple predecessor estimation selector} + Details: We estimate the number of application of {1,3,4} by application of Pre({1,3,4}) = {2,5}. Here rules are labelled as follows: 1: minus#(x,0()) -> c_1() 2: minus#(x,s(y)) -> c_2(pred#(minus(x,y)),minus#(x,y)) 3: pred#(s(x)) -> c_3() 4: quot#(0(),s(y)) -> c_4() 5: quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)) * Step 4: RemoveWeakSuffixes WORST_CASE(?,O(n^2)) + Considered Problem: - Strict DPs: minus#(x,s(y)) -> c_2(pred#(minus(x,y)),minus#(x,y)) quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)) - Weak DPs: minus#(x,0()) -> c_1() pred#(s(x)) -> c_3() quot#(0(),s(y)) -> c_4() - Weak TRS: minus(x,0()) -> x minus(x,s(y)) -> pred(minus(x,y)) pred(s(x)) -> x - Signature: {minus/2,pred/1,quot/2,minus#/2,pred#/1,quot#/2} / {0/0,s/1,c_1/0,c_2/2,c_3/0,c_4/0,c_5/2} - Obligation: innermost runtime complexity wrt. defined symbols {minus#,pred#,quot#} and constructors {0,s} + Applied Processor: RemoveWeakSuffixes + Details: Consider the dependency graph 1:S:minus#(x,s(y)) -> c_2(pred#(minus(x,y)),minus#(x,y)) -->_1 pred#(s(x)) -> c_3():4 -->_2 minus#(x,0()) -> c_1():3 -->_2 minus#(x,s(y)) -> c_2(pred#(minus(x,y)),minus#(x,y)):1 2:S:quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)) -->_1 quot#(0(),s(y)) -> c_4():5 -->_2 minus#(x,0()) -> c_1():3 -->_1 quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)):2 -->_2 minus#(x,s(y)) -> c_2(pred#(minus(x,y)),minus#(x,y)):1 3:W:minus#(x,0()) -> c_1() 4:W:pred#(s(x)) -> c_3() 5:W:quot#(0(),s(y)) -> c_4() The following weak DPs constitute a sub-graph of the DG that is closed under successors. The DPs are removed. 5: quot#(0(),s(y)) -> c_4() 3: minus#(x,0()) -> c_1() 4: pred#(s(x)) -> c_3() * Step 5: SimplifyRHS WORST_CASE(?,O(n^2)) + Considered Problem: - Strict DPs: minus#(x,s(y)) -> c_2(pred#(minus(x,y)),minus#(x,y)) quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)) - Weak TRS: minus(x,0()) -> x minus(x,s(y)) -> pred(minus(x,y)) pred(s(x)) -> x - Signature: {minus/2,pred/1,quot/2,minus#/2,pred#/1,quot#/2} / {0/0,s/1,c_1/0,c_2/2,c_3/0,c_4/0,c_5/2} - Obligation: innermost runtime complexity wrt. defined symbols {minus#,pred#,quot#} and constructors {0,s} + Applied Processor: SimplifyRHS + Details: Consider the dependency graph 1:S:minus#(x,s(y)) -> c_2(pred#(minus(x,y)),minus#(x,y)) -->_2 minus#(x,s(y)) -> c_2(pred#(minus(x,y)),minus#(x,y)):1 2:S:quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)) -->_1 quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)):2 -->_2 minus#(x,s(y)) -> c_2(pred#(minus(x,y)),minus#(x,y)):1 Due to missing edges in the depndency graph, the right-hand sides of following rules could be simplified: minus#(x,s(y)) -> c_2(minus#(x,y)) * Step 6: Decompose WORST_CASE(?,O(n^2)) + Considered Problem: - Strict DPs: minus#(x,s(y)) -> c_2(minus#(x,y)) quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)) - Weak TRS: minus(x,0()) -> x minus(x,s(y)) -> pred(minus(x,y)) pred(s(x)) -> x - Signature: {minus/2,pred/1,quot/2,minus#/2,pred#/1,quot#/2} / {0/0,s/1,c_1/0,c_2/1,c_3/0,c_4/0,c_5/2} - Obligation: innermost runtime complexity wrt. defined symbols {minus#,pred#,quot#} and constructors {0,s} + Applied Processor: Decompose {onSelection = all cycle independent sub-graph, withBound = RelativeAdd} + Details: We analyse the complexity of following sub-problems (R) and (S). Problem (S) is obtained from the input problem by shifting strict rules from (R) into the weak component. Problem (R) - Strict DPs: minus#(x,s(y)) -> c_2(minus#(x,y)) - Weak DPs: quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)) - Weak TRS: minus(x,0()) -> x minus(x,s(y)) -> pred(minus(x,y)) pred(s(x)) -> x - Signature: {minus/2,pred/1,quot/2,minus#/2,pred#/1,quot#/2} / {0/0,s/1,c_1/0,c_2/1,c_3/0,c_4/0,c_5/2} - Obligation: innermost runtime complexity wrt. defined symbols {minus#,pred#,quot#} and constructors {0,s} Problem (S) - Strict DPs: quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)) - Weak DPs: minus#(x,s(y)) -> c_2(minus#(x,y)) - Weak TRS: minus(x,0()) -> x minus(x,s(y)) -> pred(minus(x,y)) pred(s(x)) -> x - Signature: {minus/2,pred/1,quot/2,minus#/2,pred#/1,quot#/2} / {0/0,s/1,c_1/0,c_2/1,c_3/0,c_4/0,c_5/2} - Obligation: innermost runtime complexity wrt. defined symbols {minus#,pred#,quot#} and constructors {0,s} ** Step 6.a:1: PredecessorEstimationCP WORST_CASE(?,O(n^2)) + Considered Problem: - Strict DPs: minus#(x,s(y)) -> c_2(minus#(x,y)) - Weak DPs: quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)) - Weak TRS: minus(x,0()) -> x minus(x,s(y)) -> pred(minus(x,y)) pred(s(x)) -> x - Signature: {minus/2,pred/1,quot/2,minus#/2,pred#/1,quot#/2} / {0/0,s/1,c_1/0,c_2/1,c_3/0,c_4/0,c_5/2} - Obligation: innermost runtime complexity wrt. defined symbols {minus#,pred#,quot#} and constructors {0,s} + Applied Processor: PredecessorEstimationCP {onSelectionCP = any intersect of rules of CDG leaf and strict-rules, withComplexityPair = NaturalPI {shape = Mixed 2, restrict = Restrict, uargs = UArgs, urules = URules, selector = Nothing}} + Details: We first use the processor NaturalPI {shape = Mixed 2, restrict = Restrict, uargs = UArgs, urules = URules, selector = Nothing} to orient following rules strictly: 1: minus#(x,s(y)) -> c_2(minus#(x,y)) The strictly oriented rules are moved into the weak component. *** Step 6.a:1.a:1: NaturalPI WORST_CASE(?,O(n^2)) + Considered Problem: - Strict DPs: minus#(x,s(y)) -> c_2(minus#(x,y)) - Weak DPs: quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)) - Weak TRS: minus(x,0()) -> x minus(x,s(y)) -> pred(minus(x,y)) pred(s(x)) -> x - Signature: {minus/2,pred/1,quot/2,minus#/2,pred#/1,quot#/2} / {0/0,s/1,c_1/0,c_2/1,c_3/0,c_4/0,c_5/2} - Obligation: innermost runtime complexity wrt. defined symbols {minus#,pred#,quot#} and constructors {0,s} + Applied Processor: NaturalPI {shape = Mixed 2, restrict = Restrict, uargs = UArgs, urules = URules, selector = Just first alternative for predecessorEstimation on any intersect of rules of CDG leaf and strict-rules} + Details: We apply a polynomial interpretation of kind constructor-based(mixed(2)): The following argument positions are considered usable: uargs(c_2) = {1}, uargs(c_5) = {1,2} Following symbols are considered usable: {minus,pred,minus#,pred#,quot#} TcT has computed the following interpretation: p(0) = 0 p(minus) = x1 p(pred) = x1 p(quot) = 1 + 2*x1 + 2*x1*x2 + x1^2 + x2 + x2^2 p(s) = 1 + x1 p(minus#) = 7 + x2 p(pred#) = 1 p(quot#) = x1*x2 + 7*x1^2 + x2 p(c_1) = 0 p(c_2) = x1 p(c_3) = 0 p(c_4) = 0 p(c_5) = 1 + x1 + x2 Following rules are strictly oriented: minus#(x,s(y)) = 8 + y > 7 + y = c_2(minus#(x,y)) Following rules are (at-least) weakly oriented: quot#(s(x),s(y)) = 9 + 15*x + x*y + 7*x^2 + 2*y >= 9 + x + x*y + 7*x^2 + 2*y = c_5(quot#(minus(x,y),s(y)),minus#(x,y)) minus(x,0()) = x >= x = x minus(x,s(y)) = x >= x = pred(minus(x,y)) pred(s(x)) = 1 + x >= x = x *** Step 6.a:1.a:2: Assumption WORST_CASE(?,O(1)) + Considered Problem: - Weak DPs: minus#(x,s(y)) -> c_2(minus#(x,y)) quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)) - Weak TRS: minus(x,0()) -> x minus(x,s(y)) -> pred(minus(x,y)) pred(s(x)) -> x - Signature: {minus/2,pred/1,quot/2,minus#/2,pred#/1,quot#/2} / {0/0,s/1,c_1/0,c_2/1,c_3/0,c_4/0,c_5/2} - Obligation: innermost runtime complexity wrt. defined symbols {minus#,pred#,quot#} and constructors {0,s} + Applied Processor: Assumption {assumed = Certificate {spaceUB = Unknown, spaceLB = Unknown, timeUB = Poly (Just 0), timeLB = Unknown}} + Details: () *** Step 6.a:1.b:1: RemoveWeakSuffixes WORST_CASE(?,O(1)) + Considered Problem: - Weak DPs: minus#(x,s(y)) -> c_2(minus#(x,y)) quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)) - Weak TRS: minus(x,0()) -> x minus(x,s(y)) -> pred(minus(x,y)) pred(s(x)) -> x - Signature: {minus/2,pred/1,quot/2,minus#/2,pred#/1,quot#/2} / {0/0,s/1,c_1/0,c_2/1,c_3/0,c_4/0,c_5/2} - Obligation: innermost runtime complexity wrt. defined symbols {minus#,pred#,quot#} and constructors {0,s} + Applied Processor: RemoveWeakSuffixes + Details: Consider the dependency graph 1:W:minus#(x,s(y)) -> c_2(minus#(x,y)) -->_1 minus#(x,s(y)) -> c_2(minus#(x,y)):1 2:W:quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)) -->_1 quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)):2 -->_2 minus#(x,s(y)) -> c_2(minus#(x,y)):1 The following weak DPs constitute a sub-graph of the DG that is closed under successors. The DPs are removed. 2: quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)) 1: minus#(x,s(y)) -> c_2(minus#(x,y)) *** Step 6.a:1.b:2: EmptyProcessor WORST_CASE(?,O(1)) + Considered Problem: - Weak TRS: minus(x,0()) -> x minus(x,s(y)) -> pred(minus(x,y)) pred(s(x)) -> x - Signature: {minus/2,pred/1,quot/2,minus#/2,pred#/1,quot#/2} / {0/0,s/1,c_1/0,c_2/1,c_3/0,c_4/0,c_5/2} - Obligation: innermost runtime complexity wrt. defined symbols {minus#,pred#,quot#} and constructors {0,s} + Applied Processor: EmptyProcessor + Details: The problem is already closed. The intended complexity is O(1). ** Step 6.b:1: RemoveWeakSuffixes WORST_CASE(?,O(n^1)) + Considered Problem: - Strict DPs: quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)) - Weak DPs: minus#(x,s(y)) -> c_2(minus#(x,y)) - Weak TRS: minus(x,0()) -> x minus(x,s(y)) -> pred(minus(x,y)) pred(s(x)) -> x - Signature: {minus/2,pred/1,quot/2,minus#/2,pred#/1,quot#/2} / {0/0,s/1,c_1/0,c_2/1,c_3/0,c_4/0,c_5/2} - Obligation: innermost runtime complexity wrt. defined symbols {minus#,pred#,quot#} and constructors {0,s} + Applied Processor: RemoveWeakSuffixes + Details: Consider the dependency graph 1:S:quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)) -->_2 minus#(x,s(y)) -> c_2(minus#(x,y)):2 -->_1 quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)):1 2:W:minus#(x,s(y)) -> c_2(minus#(x,y)) -->_1 minus#(x,s(y)) -> c_2(minus#(x,y)):2 The following weak DPs constitute a sub-graph of the DG that is closed under successors. The DPs are removed. 2: minus#(x,s(y)) -> c_2(minus#(x,y)) ** Step 6.b:2: SimplifyRHS WORST_CASE(?,O(n^1)) + Considered Problem: - Strict DPs: quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)) - Weak TRS: minus(x,0()) -> x minus(x,s(y)) -> pred(minus(x,y)) pred(s(x)) -> x - Signature: {minus/2,pred/1,quot/2,minus#/2,pred#/1,quot#/2} / {0/0,s/1,c_1/0,c_2/1,c_3/0,c_4/0,c_5/2} - Obligation: innermost runtime complexity wrt. defined symbols {minus#,pred#,quot#} and constructors {0,s} + Applied Processor: SimplifyRHS + Details: Consider the dependency graph 1:S:quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)) -->_1 quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y)),minus#(x,y)):1 Due to missing edges in the depndency graph, the right-hand sides of following rules could be simplified: quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y))) ** Step 6.b:3: PredecessorEstimationCP WORST_CASE(?,O(n^1)) + Considered Problem: - Strict DPs: quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y))) - Weak TRS: minus(x,0()) -> x minus(x,s(y)) -> pred(minus(x,y)) pred(s(x)) -> x - Signature: {minus/2,pred/1,quot/2,minus#/2,pred#/1,quot#/2} / {0/0,s/1,c_1/0,c_2/1,c_3/0,c_4/0,c_5/1} - Obligation: innermost runtime complexity wrt. defined symbols {minus#,pred#,quot#} and constructors {0,s} + Applied Processor: PredecessorEstimationCP {onSelectionCP = any intersect of rules of CDG leaf and strict-rules, withComplexityPair = NaturalMI {miDimension = 1, miDegree = 1, miKind = Algebraic, uargs = UArgs, urules = URules, selector = Nothing}} + Details: We first use the processor NaturalMI {miDimension = 1, miDegree = 1, miKind = Algebraic, uargs = UArgs, urules = URules, selector = Nothing} to orient following rules strictly: 1: quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y))) The strictly oriented rules are moved into the weak component. *** Step 6.b:3.a:1: NaturalMI WORST_CASE(?,O(n^1)) + Considered Problem: - Strict DPs: quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y))) - Weak TRS: minus(x,0()) -> x minus(x,s(y)) -> pred(minus(x,y)) pred(s(x)) -> x - Signature: {minus/2,pred/1,quot/2,minus#/2,pred#/1,quot#/2} / {0/0,s/1,c_1/0,c_2/1,c_3/0,c_4/0,c_5/1} - Obligation: innermost runtime complexity wrt. defined symbols {minus#,pred#,quot#} and constructors {0,s} + Applied Processor: NaturalMI {miDimension = 1, miDegree = 1, miKind = Algebraic, uargs = UArgs, urules = URules, selector = Just first alternative for predecessorEstimation on any intersect of rules of CDG leaf and strict-rules} + Details: We apply a matrix interpretation of kind constructor based matrix interpretation: The following argument positions are considered usable: uargs(c_5) = {1} Following symbols are considered usable: {minus,pred,minus#,pred#,quot#} TcT has computed the following interpretation: p(0) = [0] p(minus) = [1] x1 + [0] p(pred) = [1] x1 + [0] p(quot) = [1] x1 + [8] x2 + [0] p(s) = [1] x1 + [8] p(minus#) = [8] x1 + [0] p(pred#) = [1] x1 + [1] p(quot#) = [1] x1 + [0] p(c_1) = [0] p(c_2) = [4] x1 + [2] p(c_3) = [8] p(c_4) = [1] p(c_5) = [1] x1 + [0] Following rules are strictly oriented: quot#(s(x),s(y)) = [1] x + [8] > [1] x + [0] = c_5(quot#(minus(x,y),s(y))) Following rules are (at-least) weakly oriented: minus(x,0()) = [1] x + [0] >= [1] x + [0] = x minus(x,s(y)) = [1] x + [0] >= [1] x + [0] = pred(minus(x,y)) pred(s(x)) = [1] x + [8] >= [1] x + [0] = x *** Step 6.b:3.a:2: Assumption WORST_CASE(?,O(1)) + Considered Problem: - Weak DPs: quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y))) - Weak TRS: minus(x,0()) -> x minus(x,s(y)) -> pred(minus(x,y)) pred(s(x)) -> x - Signature: {minus/2,pred/1,quot/2,minus#/2,pred#/1,quot#/2} / {0/0,s/1,c_1/0,c_2/1,c_3/0,c_4/0,c_5/1} - Obligation: innermost runtime complexity wrt. defined symbols {minus#,pred#,quot#} and constructors {0,s} + Applied Processor: Assumption {assumed = Certificate {spaceUB = Unknown, spaceLB = Unknown, timeUB = Poly (Just 0), timeLB = Unknown}} + Details: () *** Step 6.b:3.b:1: RemoveWeakSuffixes WORST_CASE(?,O(1)) + Considered Problem: - Weak DPs: quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y))) - Weak TRS: minus(x,0()) -> x minus(x,s(y)) -> pred(minus(x,y)) pred(s(x)) -> x - Signature: {minus/2,pred/1,quot/2,minus#/2,pred#/1,quot#/2} / {0/0,s/1,c_1/0,c_2/1,c_3/0,c_4/0,c_5/1} - Obligation: innermost runtime complexity wrt. defined symbols {minus#,pred#,quot#} and constructors {0,s} + Applied Processor: RemoveWeakSuffixes + Details: Consider the dependency graph 1:W:quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y))) -->_1 quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y))):1 The following weak DPs constitute a sub-graph of the DG that is closed under successors. The DPs are removed. 1: quot#(s(x),s(y)) -> c_5(quot#(minus(x,y),s(y))) *** Step 6.b:3.b:2: EmptyProcessor WORST_CASE(?,O(1)) + Considered Problem: - Weak TRS: minus(x,0()) -> x minus(x,s(y)) -> pred(minus(x,y)) pred(s(x)) -> x - Signature: {minus/2,pred/1,quot/2,minus#/2,pred#/1,quot#/2} / {0/0,s/1,c_1/0,c_2/1,c_3/0,c_4/0,c_5/1} - Obligation: innermost runtime complexity wrt. defined symbols {minus#,pred#,quot#} and constructors {0,s} + Applied Processor: EmptyProcessor + Details: The problem is already closed. The intended complexity is O(1). WORST_CASE(?,O(n^2))